package 原型模式.邮件;

import 原型模式.客户类.Customer;

public class Email implements Cloneable {
    private Attachment attachment=null;
    private String emailTitle;
    private int emailLevel;

    //浅克隆方法
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    //深克隆方法(对象克隆时调用对应的克隆方法)
    public Email deepClone() throws CloneNotSupportedException {
        Attachment att= (Attachment) attachment.clone();
        Email ema= (Email) this.clone();
        ema.setAttachment(att);
        return ema;
    }


    public Email(Attachment attachment, String emailTitle, int emailLevel) {
        this.attachment = attachment;
        this.emailTitle = emailTitle;
        this.emailLevel = emailLevel;
    }

    @Override
    public String toString() {
        return "Email{" +
                "attachment=" + attachment +
                ", emailTitle='" + emailTitle + '\'' +
                ", emailLevel=" + emailLevel +
                '}';
    }

    public Attachment getAttachment() {
        return attachment;
    }

    public void setAttachment(Attachment attachment) {
        this.attachment = attachment;
    }

    public String getEmailTitle() {
        return emailTitle;
    }

    public void setEmailTitle(String emailTitle) {
        this.emailTitle = emailTitle;
    }

    public int getEmailLevel() {
        return emailLevel;
    }

    public void setEmailLevel(int emailLevel) {
        this.emailLevel = emailLevel;
    }
}
